<?php
session_start();
if (isset($_SESSION['count'])) {
    $_SESSION['count']++;
} else
    $_SESSION['count'] = 0;

if (isset($_GET["corPref"]) == 1 && $_GET["corPref"] != "") {
    $value = $_GET["corPref"];
    setcookie("TestCookie", $value, time() + 60 * 60 * 24 * 30);
} else if (isset($_COOKIE["TestCookie"])) {
    $value = $_COOKIE["TestCookie"];
}
else
    $value = "white";
?>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body bgcolor=<?php echo $value ?>>
        <div>
            <form action="sessao2.php" method="GET">
                <b>Selecione sua cor preferida:</b><br/><br/>
                <input type="radio" name="corPref" value="blue" />Azul<br/>
                <input type="radio" name="corPref" value="green" />Verde<br/>
                <input type="radio" name="corPref" value="red" />Vermelho<br/>
                <input type="submit" name="enviar" value="Enviar" />
            </form>
        </div>
    </body>
</html>
